<?php

/**
 * Adding a ProRole
 * @package ModuleOrganisationCommunication
 * @version 1.0b
 * @return table tr
 */

session_start();

// Configuration file
include '../configuration.php';
// Functions
include '../inc/functions.php';

// Checking if user is logged in
if (!CheckSession()):
	exit();
endif;

// Include all objects
// TODO: Include only needed classes
foreach (glob($configuration['webroot'].'objects/*.php') as $class) { include_once $class; }

try {
	// Creating prorole
	$prorole = new Prorole();
	$prorole->name = $_POST['name'];
	
	// Inserting prorole into database
	$prorole->SaveNew();
	
	$msg  = '<tr><td class="del"><a href="'.$prorole->proroleId.'" class="delete-doc delete-prorole"><img src="css/img/bin_empty.png" alt="Delete" /></a></td>';
	$msg .= '<td>'.$prorole->name.'</td></tr>';
	echo $msg;
	
} catch (Exception $e) {
	echo $e->getMessage();
}
?>